<%@ Page Title="Sys_Holiday List" Language="C#" AutoEventWireup="true" CodeBehind="Sys_HolidayList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Sys_HolidayList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);

    $(function () {
        $('.form_date').datetimepicker({
            language: "zh_CN",
            format: "yyyy-mm-dd",
            autoclose: true,
            todayBtn: true,
            todayHighlight: true,
            pickerPosition: "bottom-left",
            startView: 2,
            minView: 2,
            forceParse: 0
        });
    });
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title>
                <h2><i class="fa fa-align-justify"></i><span style="font-size: 16px; padding-right: 15px;"><%: R(LanguageModule.Sys_Holiday, "Sys_Holiday", "Sys_Holiday") %></span></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <form class="form-inline">
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Holiday, "HolidayTitle", "假日标题") %>：</label>
                        <input type="email" id="HolidayTitle" name="HolidayTitle" maxlength="50" class="form-control" placeholder="<%: R(LanguageModule.Sys_Holiday, "HolidayTitle", "節日") %>">
                    </div>
                    <div class="form-group">
                        <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Holiday, "HolidayDate", "假日日期") %>：</label>
                        <div class="input-group date form_date">
                            <input id="HolidayDate" name="HolidayDate" class="form-control" size="16" type="text" readonly="readonly">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                        </div>
                    </div>
                    <button type="button" id="btnQuery" name="btnQuery" class="btn btn-default btn-ar btn-primary">
                        <i class="fa fa-search "></i>
                        <%: R(LanguageModule.M_Common, "Query") %>
                    </button>
                </form>
                <%--<form class="form" role="form">
                    <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Holiday, "HolidayTitle", "假日标题") %>：</label>
                                <input type="email" id="HolidayTitle" name="HolidayTitle" class="form-control" placeholder="<%: R(LanguageModule.Sys_Holiday, "HolidayTitle", "節日") %>">
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label class="control-label" for="RoleDesc"><%: R(LanguageModule.Sys_Holiday, "HolidayDate", "假日日期") %>：</label>
                                <div class="input-group date form_date">
                                    <input id="HolidayDate" name="HolidayDate" class="form-control" size="16" type="text" readonly="readonly">
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <button type="button" id="btnQuery" name="btnQuery" class="btn btn-ar btn-primary" style="margin-top: 25px;">
                                    <i class="fa fa-search "></i>
                                    <%: R(LanguageModule.M_Common, "Query") %>
                                </button>
                            </div>
                        </div>
                    </div>
                </form>--%>
                <div class="form-group"></div>
                <div class="col-sm-12">
                    <div class="form-group">
                        <a href="#" class="btn btn-info" onclick="loadPage('Sys/Sys_HolidayItem.aspx')"><i class="fa fa-plus"></i>
                            <%: R(LanguageModule.M_Common, "Add") %></a>
                        <a href="#" class="btn btn-info" id="btnDelete"><i class="fa fa-trash-o "></i>
                            <%: R(LanguageModule.M_Common, "Delete") %></a>
                    </div>
                </div>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>

    </div>
</div>
<script type="text/javascript">

    var dt;

    $(function () {
        dt = $('#table').DataTable({
            "ajax": {
                "url": 'Sys/Handlers/Sys_HolidayHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                    d.HolidayTitle = $('#HolidayTitle').val();
                    d.HolidayDate = $('#HolidayDate').val();
                }
            },
            "columns": [
                    { "data": 'RowIndex', "title": "#" },
                    { "data": 'HolidayID', "title": "<%: R(LanguageModule.Sys_Holiday, "HolidayID", "ID") %>", visible: false },
                    { "data": 'HolidayTitle', "title": "<%: R(LanguageModule.Sys_Holiday, "HolidayTitle", "假日标题") %>" },
                    { "data": 'HolidayDate', "title": "<%: R(LanguageModule.Sys_Holiday, "HolidayDate", "假日日期") %>" },
                    { "data": 'Status', "title": "<%: R(LanguageModule.M_Common, "Status", "状态") %>", render: fStatus },	
                  <%--  { "data": 'Memo', "title": "<%: R(LanguageModule.Sys_Holiday, "Memo", "备注") %>" },	--%>
                 <%--   { "data": 'Creator', "title": "<%: R(LanguageModule.Sys_Holiday, "Creator", "创建人") %>" },	--%>
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Sys_Holiday, "CreateTime", "创建时间") %>" },	
                  <%--  { "data": 'LastModifier', "title": "<%: R(LanguageModule.Sys_Holiday, "LastModifier", "最后一次修改人") %>" },	
                    { "data": 'LastModifyTime', "title": "<%: R(LanguageModule.Sys_Holiday, "LastModifyTime", "最后一次修改时间") %>" },--%>
            ]
        });


        $('#btnQuery').click(function () {
            dt.ajax.reload();
        });


        //delete selected row
        $('#btnDelete').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                jconfirm("<%: R(LanguageModule.M_Common, "DeleteConfirm","你确定要删除此记录吗？") %>", function () {
                    //console.log(dt.row('.selected').data());
                    $.post("Sys/Handlers/Sys_HolidayHandler.ashx?type=delete", { HolidayID: dt.row('.selected').data().HolidayID }, function (data) {
                        if (data) {
                            if (data.isSuccess) {
                                dt.ajax.reload();
                                $.gritter.add({
                                    title: '<%: R(LanguageModule.M_Common, "TipSuccess") %>',
                                    text: data.message,
                                    class_name: 'gritter-success'
                                });

                                $('#table tbody tr.selected').remove();
                            }
                        }
                    }, "json");
                });
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

        //delete selected row
        $('#btnEdit').click(function () {
            if ($('#table tbody tr.selected').length > 0) {
                loadPage("Sys/Sys_HolidayItem.aspx?HolidayID=" + dt.row('.selected').data().HolidayID);
            }
            else {
                $(".alert > .content").html("<%: R(LanguageModule.M_Common, "SelectRecord") %>");
                $(".alert").show();
            }
        });

    });
    <%--    function fnumber(value, row) {

        return value == '1' ? '<span style="color:green"><%=R(LanguageModule.M_Common, "Enable", "啟用") %></span>' : '<span style="color:red"><%=R(LanguageModule.M_Common, "Disable", "禁用") %></span>';

        }--%>
</script>
